<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document对象</title>
</head>
<body>
<div id="div1">div1</div>
<div id="div2">div2</div>
<div id="div3">div3</div>
<div class="class1">div4</div>
<div class="class1">div5</div>
<hr color="red" size="3" width="50%" align="left">

</body>
</html>
<script>
    var divs = document.getElementsByTagName("div");
    for (var i = 0; i <divs.length ; i++) {
        document.write(divs[i].innerHTML+"<br>");
    }

document.write("<hr color='red' size='3' width='50%' align='left'>")

    var classs = document.getElementsByClassName("class1");
    for (var i = 0; i < classs.length; i++) {
        document.write(classs[i].innerHTML+"<br>")
    }

</script>